function onServerConnection(server)
    -- incoming server is a previous server, we have to create RPC function to receive
    -- its publication informations
    server.publications = {}
    function server:publish(name)
        -- publication creation
        INFO("server onPublish:", name)
        self.publications[name] = mona:publish(name)
    end
    function server:unpublish(name)
        -- publication suppression
		INFO("server onunpublish",name)
        local publication = self.publications[name]
        if publication then publication:close() end
        self.publications[name] = nil
    end
    function server:video(name, time, packet)
        local publication = self.publications[name]
        -- give the video packet to our publication copy
        if publication then publication:pushVideo(time, packet) end
    end
    function server:audio(name, time, packet)
        local publication = self.publications[name]
        -- give the audio packet to our publication copy
        if publication then publication:pushAudio(time, packet) end
    end
    function server:data(name, dataname, packet)
        local publication = self.publications[name]
        -- give the data packet to our publication copy
        if publication then publication:pushData(packet) end
    end
	server:send("onConnected")
end

function onServerDisconnection(server)
    
    -- disconnected server was a previous server, close its publications
    for id, publication in pairs(server.publications) do
        publication:close()
    end
end
